package net.atomarrow.bs.interceptor;

import net.atomarrow.annotation.Priority;
import net.atomarrow.aop.ControllerInterceptor;
import net.atomarrow.action.ActionInvocation;
import net.atomarrow.ioc.ActionContext;
import net.atomarrow.render.Render;
@Priority(value=2)
public class MyInterceptor2 implements ControllerInterceptor{

    @Override
    public Render intercept(ActionInvocation actionInvocation) throws Exception {
        System.out.println("2 before");
        Render render = actionInvocation.invoke();
        System.out.println("2 after");
        
        if(ActionContext.getContext().getControllerOrInterceptorException()!=null){
        	System.out.println("捕捉到controller异常");
        	System.out.println(ActionContext.getContext().getControllerOrInterceptorException().getMessage());
        	System.out.println(ActionContext.getContext().getControllerOrInterceptorException().getCause().getMessage());
        }
         if(ActionContext.getContext().getServiceException()!=null){
        	System.out.println("捕捉到service异常");
        	System.out.println(ActionContext.getContext().getServiceException().getStackTrace()[0]);
        }
        return render;
    }
}
